******CODE TO REPLICATE ANALYSES FOR "ARE PRO-IMMIGRANT MESSAGES INEFFECTIVE?"******

*****SETTING COLOR SCHEME*****
set scheme plotplain

*****GENERATING RELEVANT VARIABLES*****
***Party camp***
gen party_camp = 1 if q6==1 | q6==2 | q6==6 | q8==1 | q8==2 | q8==6 
replace party_camp = 2 if q6==11 | q6==3 | q6==7 | q8==11 | q8==3 | q8==7 
replace party_camp = 3 if q6==12 | q6==13 | q8==12 | q8==13
replace party_camp = 4 if q6==4 | q6==9 | q6==10 | q8==4 | q8==9 | q8==10
recode party_camp (1=1) (2=2) (3=3) (4=4) (else=0)

label define partycamp 0"None" 1"SD camp" 2"V camp" 3"Extreme left" 4"Extreme right"
label values party_camp partycamp 

*****TESTING H1A-H1C*****
***Table 1***
putdocx begin
reg q15 i.message
putdocx table table1 = etable, width(100%)
putdocx save table1

*****TESTING H2*****
***Figure 1, left panel***
reg q15 i.message##i.partysponsor if party_camp==1
pwcompare message#partysponsor, group
cibar q15 if party_camp==1, over1(partysponsor) over2(message) barcol(gs3 gs11) graphopt(ytitle("") yscale(range(1 (1) 5)) ylab(1 (1) 5))
graph export fig1a.png

***Figure 1, right panel*** 
reg q15 i.message##i.partysponsor if party_camp==2
pwcompare message#partysponsor, group 
cibar q15 if party_camp==2, over1(partysponsor) over2(message) barcol(gs3 gs11) graphopt(ytitle("") yscale(range(1 (1) 5)) ylab(1 (1) 5))
graph export fig1b.png

*****APPENDIX*****
***Figure A2.1.***
reg q15 i.message
margins i.message, pwcompare(effects)
marginsplot, horizontal unique recast(scatter) yscale(reverse) xline(0) xscale(range(-0.3 0.5)) xlab(-0.3 (0.2) 0.5) ylab(1"Pro_moral_vs_Pro_non_moral" 2"Anti_non_moral_vs_Pro_non_moral" 3"Anti_moral_vs_Pro_non_moral" 4"Anti_non_moral_vs_Pro_moral" 5"Anti_moral_vs_Pro_moral" 6"Anti_moral_vs_Anti_non_moral") xtitle("") ytitle("")
graph export figa21.png

***Table A3.1.***
putdocx begin
ologit q15 i.message
putdocx table tablea31 = etable, width(100%)
putdocx save tablea31

***Figure A3.1.***
ologit q15 ib2.message
margins, dydx(message) predict(outcome(1)) predict(outcome(5))
marginsplot, unique recast(scatter) yscale(reverse) yline(0) yscale(range(-0.1 (0.05) 0.1)) ylab(-0.1 (0.05) 0.1) ytitle("Effects on probability") xlab(1"Pro_non_moral" 2"Pro_moral" 3"Anti_non_moral" 4"Anti_moral") xtitle("") plot1opts(msymbol(Oh)) plot2opts(mcolor(black) msymbol(D)) ciopts(color(black))
graph export figa31.png

***Table A4.1.***
putdocx begin 
reg q15 i.message i.partysponsor
putdocx table tablea41 = etable, width(100%)
putdocx save tablea41

***Figure A4.1.***
reg q15 i.message i.partysponsor
margins i.message i.partysponsor, pwcompare(effects)
marginsplot, horizontal unique recast(scatter) yscale(reverse) xline(0) xscale(range(-0.3 0.5)) xlab(-0.3 (0.2) 0.5) ylab(1"Pro_moral_vs_Pro_non_moral" 2"Anti_non_moral_vs_Pro_non_moral" 3"Anti_moral_vs_Pro_non_moral" 4"Anti_non_moral_vs_Pro_moral" 5"Anti_moral_vs_Pro_moral" 6"Anti_moral_vs_Anti_non_moral" 7"Venstre_vs_Socialdemokratiet") xtitle("") ytitle("")
graph export figa41.png
